<!--/*-->
<html>
	<head>
		<link rel="stylesheet" type="text/css" href="narrative.css"/>
	</head>
	<body>
<!--*/-->

<div>
	<div class="hapiHeaderText">
		<!--/*
		Show the DiagnosticReport's name.text value, or if that isn't populated, show the
		display value on the first coding, and if that's missing too show a default "Untitled"
		value 
		*/-->
		<th:block th:switch="${fhirVersion}">
			<th:block th:case="'DSTU1'">
				<th:block th:if="${not resource.name.textElement.empty}" th:text="${resource.name.textElement.value}"/>
				<th:block th:if="    ${resource.name.textElement.empty} and ${not resource.name.coding[0].displayElement.empty}" th:text="${resource.name.coding[0].display}"/>
				<th:block th:if=    "${resource.name.textElement.empty} and     ${resource.name.coding[0].displayElement.empty}" th:text="'Untitled Diagnostic Report'"/>
			</th:block>
			<th:block th:case="*">
				<th:block th:if="${not resource.code.textElement.empty} or ${resource.code.coding.empty}" th:text="${resource.code.textElement.value}"/>
				<th:block th:if="${not resource.code.coding.empty} and ${resource.code.textElement.empty} and ${not resource.code.coding[0].displayElement.empty}" th:text="${resource.code.coding[0].display}"/>
				<th:block th:if="${not resource.code.coding.empty} and ${resource.code.textElement.empty} and     ${resource.code.coding[0].displayElement.empty}" th:text="'Untitled Diagnostic Report'"/>
			</th:block>
		</th:block>
		<!--/*--> Complete Blood Count <!--*/-->
	</div>
	
	<table class="hapiPropertyTable">
		<tbody>
			<tr th:if="${not resource.statusElement.empty}">
				<td>Status</td>
				<td th:text="${resource.statusElement.value}">Final</td>
			</tr>
			<tr th:if="${not resource.issuedElement.empty}">
				<td>Issued</td>
				<td th:narrative="${resource.issuedElement}">22 March 2012</td>
			</tr>
			<tr th:if="${not resource.conclusionElement.empty}">
				<td>Conclusion</td>
				<td th:narrative="${resource.conclusionElement}">This is the conclusion text</td>
			</tr>
		</tbody>
	</table>
	
	<table class="hapiTableOfValues" th:if="${not #lists.isEmpty(resource.result)} and ${resource.result[0].resource != null}">
		<thead>
			<tr>
				<td>Name</td>
				<td>Value</td>
				<td>Interpretation</td>
				<td>Reference Range</td>
				<td>Status</td>
			</tr>
		</thead>
		<tbody>
			<th:block th:each="result,rowStat : ${resource.result}">
				<tr th:class="${rowStat.odd}? 'hapiTableOfValuesRowOdd' : 'hapiTableOfValuesRowEven'" class="hapiTableOfValuesRowOdd">
					<td>
						<th:block th:switch="${fhirVersion}">
                     <th:block th:case="'DSTU2'">
                        <th:block th:if="${not result.resource.code.textElement.empty}" th:text="${result.resource.code.textElement.value}"/>
                        <th:block th:if="${result.resource.code.textElement.empty} and ${not #lists.isEmpty(result.resource.code.coding)} and ${not result.resource.code.coding[0].empty} and ${not result.resource.code.coding[0].displayElement.empty}" th:text="${result.resource.code.coding[0].display}"/>
                        <th:block th:if="${result.resource.code.textElement.empty} and ${not #lists.isEmpty(result.resource.code.coding)} and ${not result.resource.code.coding[0].empty} and ${result.resource.code.coding[0].displayElement.empty}" th:text="'?'"/>
                     </th:block>
                     <th:block th:case="'DSTU2_HL7ORG'">
                        <th:block th:if="${not result.resource.code.textElement.empty}" th:text="${result.resource.code.textElement.value}"/>
                        <th:block th:if="${result.resource.code.textElement.empty} and ${not #lists.isEmpty(result.resource.code.coding)} and ${not result.resource.code.coding[0].empty} and ${not result.resource.code.coding[0].displayElement.empty}" th:text="${result.resource.code.coding[0].display}"/>
                        <th:block th:if="${result.resource.code.textElement.empty} and ${not #lists.isEmpty(result.resource.code.coding)} and ${not result.resource.code.coding[0].empty} and ${result.resource.code.coding[0].displayElement.empty}" th:text="'?'"/>
                     </th:block>
                     <th:block th:case="'DSTU2_1'">
                        <th:block th:if="${not result.resource.code.textElement.empty}" th:text="${result.resource.code.textElement.value}"/>
                        <th:block th:if="${result.resource.code.textElement.empty} and ${not #lists.isEmpty(result.resource.code.coding)} and ${not result.resource.code.coding[0].empty} and ${not result.resource.code.coding[0].displayElement.empty}" th:text="${result.resource.code.coding[0].display}"/>
                        <th:block th:if="${result.resource.code.textElement.empty} and ${not #lists.isEmpty(result.resource.code.coding)} and ${not result.resource.code.coding[0].empty} and ${result.resource.code.coding[0].displayElement.empty}" th:text="'?'"/>
                     </th:block>
                     <th:block th:case="'DSTU3'">
                        <th:block th:if="${not result.resource.code.textElement.empty}" th:text="${result.resource.code.textElement.value}"/>
                        <th:block th:if="${result.resource.code.textElement.empty} and ${not #lists.isEmpty(result.resource.code.coding)} and ${not result.resource.code.coding[0].empty} and ${not result.resource.code.coding[0].displayElement.empty}" th:text="${result.resource.code.coding[0].display}"/>
                        <th:block th:if="${result.resource.code.textElement.empty} and ${not #lists.isEmpty(result.resource.code.coding)} and ${not result.resource.code.coding[0].empty} and ${result.resource.code.coding[0].displayElement.empty}" th:text="'?'"/>
                     </th:block>
							<th:block th:case="*">
                        <th:block th:if="${not result.resource.code.textElement.empty}" th:text="${result.resource.code.textElement.value}"/>
                        <th:block th:if="${result.resource.code.textElement.empty} and ${not #lists.isEmpty(result.resource.code.coding)} and ${not result.resource.code.coding[0].empty} and ${not result.resource.code.coding[0].displayElement.empty}" th:text="${result.resource.code.coding[0].display}"/>
                        <th:block th:if="${result.resource.code.textElement.empty} and ${not #lists.isEmpty(result.resource.code.coding)} and ${not result.resource.code.coding[0].empty} and ${result.resource.code.coding[0].displayElement.empty}" th:text="'?'"/>
							</th:block>
						</th:block>
						<!--/*--> Hb <!--*/-->
					</td>
					<td th:narrative="${result.resource.value}">2.2 g/L</td>
					<td>
                  <th:block th:switch="${fhirVersion}">
                     <th:block th:case="'DSTU2'">
                        <th:block th:if="${not result.resource.interpretation.textElement.empty}" th:text="${result.resource.interpretation.text}"/>
                        <th:block th:if="${result.resource.interpretation.textElement.empty} and ${not result.resource.interpretation.coding.empty} and ${not result.resource.interpretation.coding[0].displayElement.empty}" th:text="${result.resource.interpretation.coding[0].display}"/>
                     </th:block>
                     <th:block th:case="'DSTU2_HL7ORG'">
                        <th:block th:if="${not result.resource.interpretation.textElement.empty}" th:text="${result.resource.interpretation.text}"/>
                        <th:block th:if="${result.resource.interpretation.textElement.empty} and ${not result.resource.interpretation.coding.empty} and ${not result.resource.interpretation.coding[0].displayElement.empty}" th:text="${result.resource.interpretation.coding[0].display}"/>
                     </th:block>
                     <th:block th:case="'DSTU2_1'">
                        <th:block th:if="${not result.resource.interpretation.textElement.empty}" th:text="${result.resource.interpretation.text}"/>
                        <th:block th:if="${result.resource.interpretation.textElement.empty} and ${not result.resource.interpretation.coding.empty} and ${not result.resource.interpretation.coding[0].displayElement.empty}" th:text="${result.resource.interpretation.coding[0].display}"/>
                     </th:block>
                     <th:block th:case="'DSTU3'">
                        <th:block th:if="${not result.resource.interpretation.textElement.empty}" th:text="${result.resource.interpretation.text}"/>
                        <th:block th:if="${result.resource.interpretation.textElement.empty} and ${not result.resource.interpretation.coding.empty} and ${not result.resource.interpretation.coding[0].displayElement.empty}" th:text="${result.resource.interpretation.coding[0].display}"/>
                     </th:block>
                     <th:block th:case="*">
                        <th:block th:if="${not result.resource.interpretation.empty} and ${not result.resource.interpretation[0].textElement.empty}" th:text="${result.resource.interpretation[0].text}"/>
                        <th:block th:if="${not result.resource.interpretation.empty} and ${result.resource.interpretation[0].textElement.empty} and ${not result.resource.interpretation[0].coding.empty} and ${not result.resource.interpretation[0].coding[0].displayElement.empty}" th:text="${result.resource.interpretation.coding[0].display}"/>
                     </th:block>
                  </th:block>
						<!--/*--> N <!--*/-->
					</td>
					<td>
						<th:block th:if="${not result.resource.referenceRange.empty} and ${not result.resource.referenceRange[0].empty}">
							<th:block th:narrative="${result.resource.referenceRange[0].low}">2.2 g/L</th:block>
							-
							<th:block th:narrative="${result.resource.referenceRange[0].high}">2.9 g/L</th:block>
						</th:block>
					</td>
					<td th:text="${result.resource.statusElement.value}">final</td>
				</tr>

				<th:block th:switch="${fhirVersion}">
					<th:block th:case="'DSTU2'">
						<tr th:if="${not result.resource.commentsElement.empty}" th:class="${rowStat.odd}? 'hapiTableOfValuesRowOdd' : 'hapiTableOfValuesRowEven'" class="hapiTableOfValuesRowOdd">
							<td th:text="${result.resource.commentsElement.value}" colspan="5">This is a comment</td>
						</tr>
					</th:block>
               <th:block th:case="'DSTU2_HL7ORG'">
                  <tr th:if="${not result.resource.commentElement.empty}" th:class="${rowStat.odd}? 'hapiTableOfValuesRowOdd' : 'hapiTableOfValuesRowEven'" class="hapiTableOfValuesRowOdd">
                     <td th:text="${result.resource.commentElement.value}" colspan="5">This is a comment</td>
                  </tr>
               </th:block>
               <th:block th:case="'DSTU2_1'">
                  <tr th:if="${not result.resource.commentElement.empty}" th:class="${rowStat.odd}? 'hapiTableOfValuesRowOdd' : 'hapiTableOfValuesRowEven'" class="hapiTableOfValuesRowOdd">
                     <td th:text="${result.resource.commentElement.value}" colspan="5">This is a comment</td>
                  </tr>
               </th:block>
               <th:block th:case="'DSTU3'">
                  <tr th:if="${not result.resource.commentElement.empty}" th:class="${rowStat.odd}? 'hapiTableOfValuesRowOdd' : 'hapiTableOfValuesRowEven'" class="hapiTableOfValuesRowOdd">
                     <td th:text="${result.resource.commentElement.value}" colspan="5">This is a comment</td>
                  </tr>
               </th:block>
					<th:block th:case="*">
						<tr th:if="${not result.resource.note.empty}" th:class="${rowStat.odd}? 'hapiTableOfValuesRowOdd' : 'hapiTableOfValuesRowEven'" class="hapiTableOfValuesRowOdd">
							<td th:text="${result.resource.note[0].text}" colspan="5">This is a comment</td>
						</tr>
					</th:block>
				</th:block>

				<!--/* The following are just examples that don't appear in the generated narrative -->
				<tr class="hapiTableOfValuesRowEven"><td>Lkc</td><td>198 g/L</td><td>H</td><td>78 g/L - 99 g/L</td><td>final</td></tr>
				<tr class="hapiTableOfValuesRowEven"><td colspan="5">Yet another comment</td></tr>
				<!--*/-->
				
			</th:block>
		</tbody>
	</table>
		
</div>


<!--/*-->
	</body>
</html>
<!--*/-->
